package com.bjsxt.system.action;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bjsxt.common.action.BaseAction;
import com.bjsxt.common.util.PageInfoUtil;
import com.bjsxt.system.pojo.Region;
import com.bjsxt.system.service.IAreaService;


@Component("areaAction")
@RequestMapping("back")
public class AreaAction extends  BaseAction
{	
	@Resource
	private IAreaService areaService; 
	@RequestMapping("/regionList.htm")
	public String regionList(HttpServletRequest req)
	{
		String realPath = req.getRealPath("");
		System.out.println(realPath);
		StringBuffer requestURL = req.getRequestURL();
		System.out.println(requestURL);
		HashMap condMap = new HashMap();
		/* 接收参数 */
		String parentId = req.getParameter("parentId");
		System.out.println("parentId:----------------"+parentId);
		String keyword = req.getParameter("keyword");
		String status = req.getParameter("status");
		String endTime = req.getParameter("endTime");
		String startTime = req.getParameter("startTime");
		if(keyword != null)
		{
			condMap.put("keyword", keyword);
		}
		if(parentId != null)
		{
			condMap.put("parentId", parentId);
		}
		if(status != null)
		{
			condMap.put("status", status);
		}
		if(endTime != null && !"".equals(endTime))
		{
			/* 将时间字符串转换成日期 */
			Date endDate = this.dateFormatUtil.format(endTime, "yyyy-MM-dd HH:mm:ss");
			condMap.put("endTime", endDate);
		}
		if(startTime != null && !"".equals(startTime))
		{
			/* 将时间字符串转换成日期 */
			Date startDate = this.dateFormatUtil.format(startTime, "yyyy-MM-dd HH:mm:ss");
			condMap.put("startTime", startDate);
		}
		PageInfoUtil pageInfoUtil = this.getPage(req);
	
		List<Region> regionList = areaService.findListRegion(pageInfoUtil, condMap);
		req.setAttribute("regionList", regionList);
		req.setAttribute("status", status);
		req.setAttribute("keyword", keyword);
		req.setAttribute("endTime", endTime);
		req.setAttribute("startTime", startTime);
		req.setAttribute("pageInfoUtil", pageInfoUtil);
		req.setAttribute("parentId", parentId);
		return "back/system/regionList";
	}
}
